package com.team.ai.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import com.team.ai.entity.Book;
import com.team.ai.entity.ResultEntity;
import com.team.ai.service.BookService;
import com.team.ai.service.SignService;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

@CrossOrigin//跨域
@RestController//遵循RestFul
@RequestMapping("v2/sign/")
public class SignController {

    @Resource
    SignService signService;
    @SaCheckLogin
    @PostMapping("insert")
    public String insert(
            @RequestParam(value = "isQd",defaultValue = "-1") int isQd
    ){
        int userId = StpUtil.getLoginIdAsInt();
        return signService.insert(isQd,userId);
    }

    @SaCheckLogin
    @PostMapping("update")
    public String update(
            @RequestParam(value = "isQd",defaultValue = "-1") int isQd
    ){
        int userId = StpUtil.getLoginIdAsInt();
        return signService.update(isQd,userId);
    }
    /**
     * 查
     * @return
     */
    @SaCheckLogin
    @GetMapping("selectList")
    public String selectList(

    ){
        int userId = StpUtil.getLoginIdAsInt();
        return  signService.selectList(userId);

    }

    /**
     * 查询书本信息
     * @param id
     * @return
     *
     */
    @SaCheckLogin
    @GetMapping("selectDetail")
    public String selectDetail(
            @RequestParam(value = "id",defaultValue = "-1") int id

    ){
        int userId = StpUtil.getLoginIdAsInt();
            return signService.selectDetail(id,userId);
    }
}
